import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


public class MyConnection {

	private static final String CLASS_NAME = "oracle.jdbc.driver.OracleDriver";
	private static final String CONNECTION_URL = "jdbc:oracle:thin:scott/tiger@127.0.0.1:1521:xe";
	
	/**
	 * Get a DB Connection.
	 * @return
	 * Return Connection
	 */
	public static Connection getConnection(){
		Connection con = null;
		
		try {
			Class.forName(CLASS_NAME);
			
			con = DriverManager.getConnection(CONNECTION_URL);
			
			
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		
		return con;
	}
	
	/**
	 * Close the DB Connection.
	 * @param con : Connection
	 */
	public static void releaseConnection(Connection con){
		try {
			if(con != null && !con.isClosed()){
				con.close();
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
